# 
#	Makefile for Emu
#	Created by Anton Barty on 4/9/10.
#	Copyright 2010 all rights reserved.
# 
#	Requires thread-safe HDF5 libraries
#	./configure --enable-threadsafe --with-pthread=/usr
#


HDF5DIR = /cfel/common
#HDF5DIR = /usr


#INC_DIR = /usr/local/include
#LIB_DIR = /usr/local/lib
INC_DIR = /cfel/common/include
LIB_DIR = /cfel/common/lib
LIBS = -lm -lstdc++ -lpthread -lhdf5 -lfftw3 -lfftw3f -lfftw3f_threads -lfftw3_threads

SHELL		= /bin/sh

CC		= g++
#CFLAGS		= -arch x86_64 -O3 -mtune=native -msse3 -mfpmath=387
#CFLAGS		= -arch x86_64 -O3 -mtune=native -msse3 -msse4 -mfpmath=sse
#CFLAGS		= -g -O3 -ffast-math -mtune=native -msse3 -msse4 -falign-double
CFLAGS		= -g -O3 -ffast-math -mtune=native -msse3 -msse4
C_FLAGS		= -I$(INC_DIR) -I$(HDF5DIR)/include $(CFLAGS) -c

LD		= g++
#LDFLAGS 	= -arch x86_64 -g -O3 -ffast-math -mtune=native
#LDFLAGS 	= -g -O3 -ffast-math -mtune=native -msse3 -msse4 -falign-double
LDFLAGS 	= -g -O3 -ffast-math -mtune=native -msse3 -msse4
#LD_FLAGS	= -L$(LIB_DIR) -L$(HDF5DIR)/lib -Wl,-rpath=$(HDF5DIR)/lib $(LIBS) $(LDFLAGS)
LD_FLAGS	= -L$(LIB_DIR) -L$(HDF5DIR)/lib $(LIBS) $(LDFLAGS)


OBJ_FILES	= phaseit3d.o global.o settings.o data2d.o data3d.o fftwData.o worker.o
EXE_FILE	= phaseit3d


.cpp.o : Makefile $*.h
	$(CC) $(C_FLAGS) $*.cpp -o $*.o

all : $(OBJ_FILES) Makefile
	$(LD) $(OBJ_FILES) $(LD_FLAGS) -o $(EXE_FILE)

clean : 
	rm $(OBJ_FILES)
